﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using FluentValidation.Attributes;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc;
using Nop.Web.Framework.Validators;
using Nop.Services.Localization;
using FluentValidation;
using Nop.Core.Domain.WindAlert;

namespace Nop.Web.Models.WindAlert
{
     [Validator(typeof(AlertValidator))]
    public partial class AlertModel : BaseNopEntityModel
    {
        public AlertModel()
        {
            AvailableSpotsGroups = new List<SelectListItem>();
        }
        [NopResourceDisplayName("Windalert.Alert.SelectSpotsGroup")]
        public int SpotsGroupId { get; set; }
        public IList<SelectListItem> AvailableSpotsGroups { get; set; }
        public SpotsGroup SpotsGroup { get; set; }
        public string Intensity { get; set; }

        public string AlertOptionName { get; set; }
        public int AlertOptionId { get; set; }

        public string IntensityString { get; set; }
        public string ExampleString { get; set; }

    }

    public class AlertValidator : BaseNopValidator<AlertModel>
    {
        public AlertValidator(ILocalizationService localizationService)
        {
            RuleFor(x => x.SpotsGroupId)
                .NotEqual(0)
                .WithMessage(localizationService.GetResource("Windalert.Alert.SpotsGroupId.Required"));
            //RuleFor(x => x.Intensity).NotEmpty().WithMessage(localizationService.GetResource("Windalert.Alert.Indensity.Required"));
            
        }
    }

}